package main.java.controller;

import main.java.dao.PatientDao;
import main.java.dao.impl.PatientDaoImpl;
import main.java.polo.Patient;

import java.util.List;
import java.util.Scanner;
public class PatientController {
    public static int insert()
    {
        PatientDao patientDao = new PatientDaoImpl();
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入病人姓名，病历号，病史");
        String patientName = scanner.next();
        String patientRecord = scanner.next();
        String patientHistory = scanner.next();
        Patient patient = new Patient(null,patientName,patientRecord,patientHistory);
        return patientDao.insert(patient);
    }

    public static void selectAll() {
        PatientDao patientDao = new PatientDaoImpl();
        List<Patient> patientList = patientDao.selectAll();
        for (Patient patient : patientList) {
            System.out.println(patient);
        }
    }

    public static int delete() {
        PatientDao patientDao = new PatientDaoImpl();
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入病人id");
        int patientId = scanner.nextInt();
        return patientDao.delete(patientId);
    }
}
